//
//  TravelsFirst_TravelsDetailsHeadTableView.m
//  艾听歌
//
//  Created by dllo on 16/5/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TravelsFirst_TravelsDetailsHeaderTableView.h"
#import "ModuleFirst_UserInformationModel.h"


#define ViewW self.frame.size.width
#define ViewH self.frame.size.height


@interface TravelsFirst_TravelsDetailsHeaderTableView ()

@property (nonatomic, strong)UIImageView *userImageView;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UILabel *dataLabel;


@end

@implementation TravelsFirst_TravelsDetailsHeaderTableView


- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubViews];
    }
    
    return self;
}

- (void)createSubViews{
    
    self.userImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, ViewW / 4 - 20, ViewH - 20)];
    self.userImageView.backgroundColor = [UIColor yellowColor];
    self.userImageView.layer.masksToBounds = YES;
    self.userImageView.layer.cornerRadius = (ViewW / 4 - 20) / 2;
    self.userImageView.userInteractionEnabled = YES;
    [self addSubview:self.userImageView];
    
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ViewW / 4 + 10, 10, ViewW / 4 * 3 - 20, (ViewH - 20) / 2)];
    self.nameLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:self.nameLabel];

    
    self.dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(ViewW / 4 + 10, (ViewH - 20) / 2 + 10, ViewW / 4 * 3 - 20, (ViewH - 20) / 2)];
    self.dataLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:self.dataLabel];
    
    //加轻拍手势
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap1Action)];
    
    
    
    [self.userImageView addGestureRecognizer:tap1];
    
}


- (void)setHeaderModel:(ModuleFirst_TravelsDetailsBigModel *)headerModel{
    
    _headerModel = headerModel;
    
    ModuleFirst_UserInformationModel *userModel =headerModel.userModel;
//    NSLog(@"%@", userModel.image);
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:userModel.image] placeholderImage:[UIImage imageNamed:@"holderr"]];
    
    self.nameLabel.text = _headerModel.name;
    self.nameLabel.textColor = [UIColor whiteColor];
    self.nameLabel.font = [UIFont systemFontOfSize:18];
    
    NSString *start_data = _headerModel.start_date;
    start_data = [NSString stringWithFormat:@"%@/%@图", start_data, _headerModel.photos_count];
    self.dataLabel.text = start_data;
    self.dataLabel.textColor = [UIColor whiteColor];
    
}

//轻拍实现方法
- (void) tap1Action{
    
    
    self.toUserHomePage();
    
}




@end
